home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 22 / Amiga Format AFCD22 (Jan 1998, Issue 106).iso / -in_the_mag- / converters / graphics / netpbm / pbmrexx / manual / file.man < prev    next >
Text File  |  1997-11-16  |  14KB  |  397 lines

  1.  
  2.  
  3.  
  4.      FILE(1)        AMIGA (Copyright but distributable)        FILE(1)
  5.  
  6.  
  7.  
  8.      NAME
  9.           file - determine file type
  10.  
  11.      SYNOPSIS
  12.           file [ -c ] [ -z ] [ -L ] [ -f namefile ] [ -m magicfile ]
  13.           file ...
  14.  
  15.      DESCRIPTION
  16.           File tests each argument in an attempt to classify it.
  17.           There are three sets of tests, performed in this order:
  18.           filesystem tests, magic number tests, and language tests.
  19.           The first test that succeeds causes the file type to be
  20.           printed.
  21.  
  22.           The type printed will usually contain one of the words text
  23.           (the file contains only ASCII characters and is probably
  24.           safe to read on an ASCII terminal), executable (the file
  25.           contains the result of compiling a program in a form
  26.           understandable to some UNIX kernel or another), or data
  27.           meaning anything else (data is usually `binary' or non-
  28.           printable).  Exceptions are well-known file formats (core
  29.           files, tar archives) that are known to contain binary data.
  30.           When modifying the file /etc/magic or the program itself,
  31.           preserve these keywords . People depend on knowing that all
  32.           the readable files in a directory have the word ``text''
  33.           printed.  Don't do as Berkeley did - change ``shell commands
  34.           text'' to ``shell script''.
  35.  
  36.           The filesystem tests are based on examining the return from
  37.           a stat(2) system call.  The program checks to see if the
  38.           file is empty, or if it's some sort of special file.  Any
  39.           known file types appropriate to the system you are running
  40.           on (sockets, symbolic links, or named pipes (FIFOs) on those
  41.           systems that implement them) are intuited if they are
  42.           defined in the system header file sys/stat.h.
  43.  
  44.           The magic number tests are used to check for files with data
  45.           in particular fixed formats.  The canonical example of this
  46.           is a binary executable (compiled program) a.out file, whose
  47.           format is defined in a.out.h and possibly exec.h in the
  48.           standard include directory.  These files have a `magic
  49.           number' stored in a particular place near the beginning of
  50.           the file that tells the UNIX operating system that the file
  51.           is a binary executable, and which of several types thereof.
  52.           The concept of `magic number' has been applied by extension
  53.           to data files.  Any file with some invariant identifier at a
  54.           small fixed offset into the file can usually be described in
  55.           this way.  The information in these files is read from the
  56.           magic file /etc/magic.
  57.  
  58.           If an argument appears to be an ASCII file, file attempts to
  59.           guess its language.  The language tests look for particular
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 1/23/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      FILE(1)        AMIGA (Copyright but distributable)        FILE(1)
  71.  
  72.  
  73.  
  74.           strings (cf names.h) that can appear anywhere in the first
  75.           few blocks of a file.  For example, the keyword .br
  76.           indicates that the file is most likely a troff input file,
  77.           just as the keyword struct indicates a C program.  These
  78.           tests are less reliable than the previous two groups, so
  79.           they are performed last.  The language test routines also
  80.           test for some miscellany (such as tar archives) and
  81.           determine whether an unknown file should be labeled as
  82.           `ascii text' or `data'.
  83.  
  84.           Use -m file to specify an alternate file of magic numbers.
  85.  
  86.           The -z tries to look inside compressed files.
  87.  
  88.           The -c option causes a checking printout of the parsed form
  89.           of the magic file.  This is usually used in conjunction with
  90.           -m to debug a new magic file before installing it.
  91.  
  92.           The -f namefile option specifies that the names of the files
  93.           to be examined are to be read (one per line) from namefile
  94.           before the argument list.  Either namefile or at least one
  95.           filename argument must be present; to test the standard
  96.           input, use ``-'' as a filename argument.
  97.  
  98.           The -L option causes symlinks to be followed, as the like-
  99.           named option in ls(1).
  100.  
  101.      FILES
  102.           /etc/magic - default list of magic numbers
  103.  
  104.      SEE ALSO
  105.           magic(5) - description of magic file format.
  106.           Strings(1), od(1) - tools for examining non-textfiles.
  107.  
  108.      STANDARDS CONFORMANCE
  109.           This program is believed to exceed the System V Interface
  110.           Definition of FILE(CMD), as near as one can determine from
  111.           the vague language contained therein. Its behavior is mostly
  112.           compatible with the System V program of the same name.  This
  113.           version knows more magic, however, so it will produce
  114.           different (albeit more accurate) output in many cases.
  115.  
  116.           The one significant difference between this version and
  117.           System V is that this version treats any white space as a
  118.           delimiter, so that spaces in pattern strings must be
  119.           escaped.  For example,
  120.           >10  string    language impress    (imPRESS data)
  121.           in an existing magic file would have to be changed to
  122.           >10  string    language\ impress   (imPRESS data)
  123.           In addition, in this version, if a pattern string contains a
  124.           backslash, it must be escaped.  For example
  125.           0    string         \begindata     Andrew Toolkit document
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 1/23/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      FILE(1)        AMIGA (Copyright but distributable)        FILE(1)
  137.  
  138.  
  139.  
  140.           in an existing magic file would have to be changed to
  141.           0    string         \\begindata    Andrew Toolkit document
  142.  
  143.           SunOS releases 3.2 and later from Sun Microsystems include a
  144.           file(1) command derived from the System V one, but with some
  145.           extensions.  My version differs from Sun's only in minor
  146.           ways.  It includes the extension of the `&' operator, used
  147.           as, for example,
  148.           >16  long&0x7fffffff     >0        not stripped
  149.  
  150.      MAGIC DIRECTORY
  151.           The magic file entries have been collected from various
  152.           sources, mainly USENET, and contributed by various authors.
  153.           Ian Darwin (address below) will collect additional or
  154.           corrected magic file entries.  A consolidation of magic file
  155.           entries will be distributed periodically.
  156.  
  157.           The order of entries in the magic file is significant.
  158.           Depending on what system you are using, the order that they
  159.           are put together may be incorrect.  If your old file command
  160.           uses a magic file, keep the old magic file around for
  161.           comparison purposes (rename it to /etc/magic.orig).
  162.  
  163.      HISTORY
  164.           There has been a file command in every UNIX since at least
  165.           Research Version 6 (man page dated January, 1975).  The
  166.           System V version introduced one significant major change:
  167.           the external list of magic number types.  This slowed the
  168.           program down slightly but made it a lot more flexible.
  169.  
  170.           This program, based on the System V version, was written by
  171.           Ian Darwin without looking at anybody else's source code.
  172.  
  173.           John Gilmore revised the code extensively, making it better
  174.           than the first version.  Geoff Collyer found several
  175.           inadequacies and provided some magic file entries.  The
  176.           program has undergone continued evolution since.
  177.  
  178.      AUTHOR
  179.           Written by Ian F. Darwin, UUCP address {utzoo |
  180.           ihnp4}!darwin!ian, Internet address ian@sq.com, postal
  181.           address: P.O. Box 603, Station F, Toronto, Ontario, CANADA
  182.           M4Y 2L8.
  183.  
  184.           Altered by Rob McMahon, cudcv@warwick.ac.uk, 1989, to extend
  185.           the `&' operator from simple `x&y != 0' to `x&y op z'.
  186.  
  187.           Altered by Guy Harris, guy@auspex.com, 1993, to:
  188.  
  189.                put the ``old-style'' `&' operator back the way it was,
  190.                because 1) Rob McMahon's change broke the previous
  191.                style of usage, 2) the SunOS ``new-style'' `&'
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 1/23/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      FILE(1)        AMIGA (Copyright but distributable)        FILE(1)
  203.  
  204.  
  205.  
  206.                operator, which this version of file supports, also
  207.                handles `x&y op z', and 3) Rob's change wasn't
  208.                documented in any case;
  209.  
  210.                put in multiple levels of `>';
  211.  
  212.                put in ``beshort'', ``leshort'', etc. keywords to look
  213.                at numbers in the file in a specific byte order, rather
  214.                than in the native byte order of the process running
  215.                file.
  216.  
  217.           Changes by Ian Darwin and various authors including Christos
  218.           Zoulas (christos@ee.cornell.edu), 1990-1992.
  219.  
  220.      LEGAL NOTICE
  221.           Copyright (c) Ian F. Darwin, Toronto, Canada, 1986, 1987,
  222.           1988, 1989, 1990, 1991, 1992, 1993.
  223.  
  224.           This software is not subject to and may not be made subject
  225.           to any license of the American Telephone and Telegraph
  226.           Company, Sun Microsystems Inc., Digital Equipment Inc.,
  227.           Lotus Development Inc., the Regents of the University of
  228.           California, The X Consortium or MIT, or The Free Software
  229.           Foundation.
  230.  
  231.           This software is not subject to any export provision of the
  232.           United States Department of Commerce, and may be exported to
  233.           any country or planet.
  234.  
  235.           Permission is granted to anyone to use this software for any
  236.           purpose on any computer system, and to alter it and
  237.           redistribute it freely, subject to the following
  238.           restrictions:
  239.  
  240.           1. The author is not responsible for the consequences of use
  241.           of this software, no matter how awful, even if they arise
  242.           from flaws in it.
  243.  
  244.           2. The origin of this software must not be misrepresented,
  245.           either by explicit claim or by omission.  Since few users
  246.           ever read sources, credits must appear in the documentation.
  247.  
  248.           3. Altered versions must be plainly marked as such, and must
  249.           not be misrepresented as being the original software.  Since
  250.           few users ever read sources, credits must appear in the
  251.           documentation.
  252.  
  253.           4. This notice may not be removed or altered.
  254.  
  255.           A few support files (getopt, strtok) distributed with this
  256.           package are by Henry Spencer and are subject to the same
  257.           terms as above.
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 1/23/95)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      FILE(1)        AMIGA (Copyright but distributable)        FILE(1)
  269.  
  270.  
  271.  
  272.           A few simple support files (strtol, strchr) distributed with
  273.           this package are in the public domain; they are so marked.
  274.  
  275.           The files tar.h and is_tar.c were written by John Gilmore
  276.           from his public-domain tar program, and are not covered by
  277.           the above restrictions.
  278.  
  279.      BUGS
  280.           There must be a better way to automate the construction of
  281.           the Magic file from all the glop in Magdir. What is it?
  282.           Better yet, the magic file should be compiled into binary
  283.           (say, ndbm(3) or, better yet, fixed-length ASCII strings for
  284.           use in heterogenous network environments) for faster
  285.           startup.  Then the program would run as fast as the Version
  286.           7 program of the same name, with the flexibility of the
  287.           System V version.
  288.  
  289.           File uses several algorithms that favor speed over accuracy,
  290.           thus it can be misled about the contents of ASCII files.
  291.  
  292.           The support for ASCII files (primarily for programming
  293.           languages) is simplistic, inefficient and requires
  294.           recompilation to update.
  295.  
  296.           There should be an ``else'' clause to follow a series of
  297.           continuation lines.
  298.  
  299.           The magic file and keywords should have regular expression
  300.           support.  Their use of ASCII TAB as a field delimiter is
  301.           ugly and makes it hard to edit the files, but is entrenched.
  302.  
  303.           It might be advisable to allow upper-case letters in
  304.           keywords for e.g., troff commands vs man page macros.
  305.           Regular expression support would make this easy.
  306.  
  307.           The program doesn't grok FORTRAN.  It should be able to
  308.           figure FORTRAN by seeing some keywords which appear indented
  309.           at the start of line.  Regular expression support would make
  310.           this easy.
  311.  
  312.           The list of keywords in ascmagic probably belongs in the
  313.           Magic file.  This could be done by using some keyword like
  314.           `*' for the offset value.
  315.  
  316.           Another optimisation would be to sort the magic file so that
  317.           we can just run down all the tests for the first byte, first
  318.           word, first long, etc, once we have fetched it.  Complain
  319.           about conflicts in the magic file entries.  Make a rule that
  320.           the magic entries sort based on file offset rather than
  321.           position within the magic file?
  322.  
  323.           The program should provide a way to give an estimate of
  324.  
  325.  
  326.  
  327.      Page 5                                          (printed 1/23/95)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      FILE(1)        AMIGA (Copyright but distributable)        FILE(1)
  335.  
  336.  
  337.  
  338.           ``how good'' a guess is.  We end up removing guesses (e.g.
  339.           ``From '' as first 5 chars of file) because they are not as
  340.           good as other guesses (e.g. ``Newsgroups:'' versus "Return-
  341.           Path:").  Still, if the others don't pan out, it should be
  342.           possible to use the first guess.
  343.  
  344.           This program is slower than some vendors' file commands.
  345.  
  346.           This manual page, and particularly this section, is too
  347.           long.
  348.  
  349.      AVAILABILITY
  350.           You can obtain the original author's latest version by
  351.           anonymous FTP on ftp.cs.toronto.edu in the directory
  352.           /pub/darwin/file.
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                                          (printed 1/23/95)
  394.  
  395.  
  396.  
  397.